package com.telit.dispose.dao.resourceManagement;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.telit.dispose.entity.FireResourceCategory;
import com.telit.dispose.model.QryDeviceModel;
import com.telit.dispose.model.QryResourceModel;
import com.telit.dispose.vo.resourceManagement.ResourceCategoryVO;
import io.lettuce.core.dynamic.annotation.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * FireResourceCategoryDao
 *
 * @author yuezhuang
 * @date 2022-08-29
 */
@Repository
public interface FireResourceCategoryDao extends BaseMapper<FireResourceCategory> {

    @Update("update fire_resource_category set img = #{img} where id = #{id}")
    void updateResource(@Param("img") String img, @Param("id") Long id);


    @Select("select img from fire_resource_category where cat_name=#{name} and deleted=false limit 1  ")
    String selectImgByName(@Param("name") String name);

    @Select("select icon_img from fire_resource_category where cat_name=#{name} and deleted=false limit 1")
    String selectIconImgByName(@Param("name") String name);

    List<ResourceCategoryVO> selectListByParentId(@Param("parentId") Long parentId);

    @Update("update fire_resource_category set deleted = true where cat_name = #{tableName}")
    void updateDelete(@Param("tableName") String tableName);


//    void updateCategory(@Param("updateResourceCategoryDTO") UpdateResourceCategoryDTO updateResourceCategoryDTO);

    void updateCategory(@Param("category") Long category, @Param("categoryName") String categoryName,
                        @Param("imgUrl") String imgUrl, @Param("iconImg") String iconImg,
                        @Param("resourceName") String resourceName);

    @Select("${selectSql}")
    List<QryResourceModel> executeSelect(@Param("selectSql") String selectSql);

    @Select("${selectSql}")
    List<QryDeviceModel> executeSelect2(@Param("selectSql") String selectSql);

    @Select("${selectSql}")
    QryDeviceModel executeSelect3(@Param("selectSql") String selectSql);

    @Select("${selectSql}")
    QryResourceModel executeSelect4(@Param("selectSql") String selectSql);

    @Select("${countSql}")
    long executeCount(@Param("countSql") String countSql);

}
